package com.woniu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniu.entity.vo.OrderByIdVO;
import com.woniu.entity.vo.UserDetailedStatisticsVO;
import com.woniu.pojo.User;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;

import java.util.List;

/**
* @author Ma.Lei
* @description 针对表【t_user】的数据库操作Mapper
* @createDate 2022-12-16 23:28:28
* @Entity generator.domain.User
*/
public interface UserMapper extends BaseMapper<User> {

    @Update("update t_user set `status` = #{status} where `id` = #{id};")
    int disabledUser(String id,Integer status);
    @Select("select * from t_user WHERE phone=#{phone}")
    User getByPhone(String phone);

    @Update("UPDATE t_user t set t.last_login_time = #{loginTime} WHERE t.phone = #{phone}")
    void setLoginTime(String phone, Date loginTime);

    @Select("select * from t_user WHERE id = #{userId} and password = #{oldPwd}")
    @ResultType(User.class)
    User checkOldPwd(String userId, String oldPwd);

    @Update("UPDATE t_user set `password`= #{newPwd} WHERE id = #{userId}")
    boolean updatePwd(String userId, String newPwd);


    @Select("select o.id,o.order_code,o.create_time,c.car_number,o.price,o.order_status\n" +
            "\tfrom t_car c,t_order o\n" +
            "\twhere c.id = o.car_id\n" +
            "\tand o.is_deleted = 0\n" +
            "\tand o.user_id=#{id}")
    List<OrderByIdVO> getOrderRecordByUserId(String id);



    UserDetailedStatisticsVO UserDetailedStatisticsById(@Param("id") String id);
}




